<?php


namespace Tests\Feature\Asset;


use App\Models\Asset;
use App\Models\AssetAffiliation;
use App\Models\AssetBrand;
use App\Models\AssetKeeper;
use App\Models\AssetLocation;
use App\Models\AssetVendor;

trait AssetControllerTestTrait
{

    protected function prepareAssetsForSearchable(String $nameSeed = "_name_seed_", int $count = 1, string $clazz = Asset::class): array
    {
        $index = 0;
        $collect = array();
        while ($index < $count) {
            $brand = factory(AssetBrand::class)->create([
                'name' => $nameSeed . '_brand_' . $index
            ]);
            $affiliation = factory(AssetAffiliation::class)->create([
                'name' => $nameSeed . '_affiliation_' . $index
            ]);
            $keeper = factory(AssetKeeper::class)->create([
                'name' => $nameSeed . '_keeper_' . $index
            ]);
            $vender = factory(AssetVendor::class)->create([
                'name' => $nameSeed . '_vendor_' . $index
            ]);
            $location = factory(AssetLocation::class)->create([
                'name' => $nameSeed . '_location_' . $index
            ]);
            $asset = factory($clazz)->create([
                'name' => $nameSeed . '_asset_' . $index,
                'brand_id' => $brand->id,
                'affiliation_id' => $affiliation->id,
                'keeper_id' => $keeper->id,
                'vendor_id' => $vender->id,
                'location_id' => $location->id
            ]);
            array_push($collect, $asset);
            $index++;
        }
        return $collect;
    }
}